package com.guoyw.leetcode.question.answer;

/**
 * @Description: 206. 反转链表
 * @Author: guoyw
 * @CreateDate: 2021/3/25 6:07 下午
 * @Version: 1.0
 */

public class C206 {

  public ListNode reverseList(ListNode head) {

    ListNode curr = head;
    ListNode prev = null;
    while(curr != null){
      ListNode next = curr.next;
      curr.next = prev;
      prev =curr;
      curr = next;
    }
    return prev;
  }


    public class ListNode {
       int val;
        ListNode next;
        ListNode() {}
        ListNode(int val) { this.val = val; }
        ListNode(int val, ListNode next) { this.val = val; this.next = next; }
    }
}
